package com.xiaoyu.system.controller;


import com.xiaoyu.system.properties.NacosTestProperties;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author zgb
 * @desc ...
 * @date 2022-04-17 19:05:42
 */
@Slf4j
@RefreshScope
@RestController
@RequestMapping("nacos")
public class NacosController {
    //微服务springcloud 动态配置需要使用@RefreshScope，如果数据库需要动态配置，则不能使用数据库自动配置，需要手动创建数据源bean并加上@RefreshScope
    @Autowired
    NacosTestProperties nacosTestProperties;


    @Value("${nacostest.desc}")
    private String desc;

    @GetMapping("/sessionId")
    public String sessionId(@RequestHeader String sessionId) {
        return sessionId;
    }

  
    @GetMapping("/testNacosTestProperties")
    public String testNacosTestProperties() {
        return nacosTestProperties.getDesc();
    }


    @GetMapping("/testValue")
    public String testValue() {
        return desc;
    }




}
